// import { NavigateFunction, useNavigate } from 'react-router-dom'
import { v4 as uuidv4 } from 'uuid'

export const getStorage = (param: string) => {
  return localStorage.getItem(param) || sessionStorage.getItem(param)
  // return getCookie(param)
}
export const getUId = () => {
  return uuidv4().split('-')[0]
}

// export const navigate: NavigateFunction = () => {
//   return useNavigate()
// }

//从cookie中获取 响应字段值
export const getCookie = (name: string) => {
  const arrCookie = document.cookie.split(';')
  //遍历匹配
  for (let i = 0; i < arrCookie.length; i++) {
    const item = arrCookie[i].split('=')
    if (item[0] == name) {
      return item[1]
    }
  }
  return ''
}
